	{layout name="common/layout" /}
	<style>
	input[type="button"]{
		border-radius: 5px;
	}
	</style>
<div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:void(0);" onClick="displaynavbar(this)"></a></div>

<div class="Hui-article-box" style="margin-top: 37px;">
		<div class="newCrumbs ">物流模板
				<span class="c-gray en">&gt;</span> 添加归还地址模板
			</div>
	<div class="Hui-article">
			
			<form action="" style="margin-bottom: 30px;background:#f3f3f3">
						<div class="mac-top">
							<label for="" class="mac-lab">
								<span>收货人姓名：</span>
								<input type="text" class="input-text radius size-M adname" placeholder="请输入收货人姓名">
							</label><br>
							<label for="" class="cl mac-lab">
								<div style="float: left;margin-left: 50px;margin-top: 20px;"><span>&nbsp;&nbsp;&nbsp;收货地址：</span></div>
								<select id="province" style="width: 140px;height: 24px;margin-left:-10px; margin-top: 20px;"></select>
								<select id="city" style="width: 140px;height: 24px;margin-left: 32px;"></select>
								<select id="area" style="width: 140px;height: 24px;margin-left: 32px;"></select>
							</label><br>
							<label for="" class="mac-lab">
								<span>&nbsp;&nbsp;&nbsp;详细地址：</span>
								<input type="text" class="input-text radius size-M address" placeholder="请输入详细地址">
							</label><br>
							<label for="" class="mac-lab">
								<span>&nbsp;&nbsp;&nbsp;邮政编码：</span>
								<input type="text" class="input-text radius size-M mall" placeholder="请输入邮编">
							</label><br>
							<label for="" class="mac-lab">
								<span>&nbsp;&nbsp;&nbsp;手机号码：</span>
								<input type="text" class="input-text radius size-M phone" placeholder="请输入手机号码">
							</label>
						</div>			
				 	<div class="btn-l">
					 	<input type="button" class="btn" onclick="upd()" value="保存">
					 	<input type="button" class="btn" value="返回" style="margin-left: 20px;">
					</div>	
			</form>
	</div>
</div>
	
 
 
<script type="text/javascript" src="__MERCHANT_STATIC__/style/js/jquery.provincesCity.js"></script>
<script language="javascript" src="__MERCHANT_STATIC__/style/js/PCASClass.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
<script>

$("input[value='返回']").click(function(){
	window.history.back();
});
	function upd(){
		var adname=$('.adname').val();
		var pro_name=$('#province>option:selected').html();
		var city_name=$('#city>option:selected').html();
		var area_name=$('#area>option:selected').html();
		var address=$('.address').val();
		var mall=$('.mall').val();
		var phone=$('.phone').val();
		$.post('{:url('do_add')}',{region:area_name,province:pro_name,city:city_name,name:adname,tel:phone,address:address,postcode:mall},function(res){
			if(res.status==1){
				location.href="{:url('index')}";
			}
		})
	}
	province();
	function province(){
		$.ajax({
			type:"get",
			url:"__MERCHANT_STATIC__/area.json",
			dataType:"json",
			async:true,
			success:function(res){
				//console.log(res.probinces);
				var str_pro = '';
				$.each(res.probinces, function(i) {
					str_pro += '<option value="'+res.probinces[i].provinceid+'">'+res.probinces[i].province+'</option>';
				});
				$("#province").html( str_pro );
				$("#province").trigger("change");
			}
		});
	}
	$("#province").change(function(){
		city( $(this).val() );
	})
	function city( province_id ){
		$.ajax({
			type:"get",
			url:"__MERCHANT_STATIC__/area.json",
			dataType:"json",
			async:true,
			success:function(res){
				//console.log(res.probinces);
				var str_city = '';
				$.each(res.probinces, function(i) {
					if(res.probinces[i].provinceid == province_id){
						$.each(res.probinces[i].cities, function(j) {
							str_city += '<option value="'+res.probinces[i].cities[j].cityid+'">'+res.probinces[i].cities[j].city+'</option>'
						});
					}
				});
				$("#city").html( str_city );
				$("#city").trigger("change");
			}
		});
	}

	$("#city").change(function(){
		area( $("#province").val(),$(this).val() );
	})

	function area( province_id,city_id ) {
		//console.log(province_id, city_id)
		$.ajax({
			type: "get",
			url: "__MERCHANT_STATIC__/area.json",
			dataType: "json",
			async: true,
			success: function (res) {
				//console.log(res);
				var str_area = '';
				$.each(res.probinces, function (i) {
					if (res.probinces[i].provinceid == province_id) {
						$.each(res.probinces[i].cities, function (j) {
							if (res.probinces[i].cities[j].cityid == city_id) {
								$.each(res.probinces[i].cities[j].areas, function (k) {
									str_area += '<option value="' + res.probinces[i].cities[j].areas[k].areaid + '">' + res.probinces[i].cities[j].areas[k].area + '</option>'
								});
							}
						});
					}
				});
				$("#area").html(str_area);
			}
		});
	}
</script>
 